package PatientManagement

import (
	"MedicalTreatment/global"
	model "MedicalTreatment/model"
	"fmt"
	"github.com/gin-gonic/gin"
)

func DelectPat(r *gin.Engine) {
	r.POST("/delectPat", func(context *gin.Context) {
		var pat model.Patient
		if err := context.ShouldBindJSON(&pat); err != nil {
			fmt.Println(err)
			context.JSON(200, gin.H{
				"Msg": err,
			})
		} else {
			if err := global.DB.Where("id=?", pat.ID).Unscoped().Delete(&model.Patient{}).Error; err != nil {
				fmt.Println(err)
				context.JSON(200, gin.H{
					"Msg": err,
				})
			} else {
				context.JSON(200, gin.H{
					"Msg": "删除成功",
				})
			}
		}
	})
}
